<!-- /**
** @descerpion:这是传统的饼图
 */ -->
<template>
  <div>
    <Echart
      id="centreLeft1Charttwo"
      :options="options"
      :height="nowheight"
      :width="nowwidth"
    />
  </div>
</template>

<script>
import Echart from "../../baseMain/index.vue";
export default {
  components: {
    Echart
  },
  props: {
    zhtitle: {
      type: String,
      default: () => ""
    },
    nowwidth: {
      type: String,
      default: () => "3.25rem"
    },
    nowheight: {
      type: String,
      default: () => "2.25rem"
    },
    cdata: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      options: {}
    };
  },
  watch: {
    cdata: {
      handler(newData) {
        this.options = {
          color: [
            "#57d2a3",
            "#eeb91c",
            "#5b8ff9",
            "#32c5e9",
            "#fb7293",
            "#8378ea",
            "#37a2da",
            "#e7bcf3",
            "#ffdb5c"
          ],
          tooltip: {
            trigger: 'item', // 数据项图形触发
            formatter: '{a} <br/>{b}: {c} ({d}%)' // 展示格式
          },
          toolbox: {
            show: true
          },
          grid: {
            left: "0",
            right: "20",
            bottom: "1%",
            top: "10",
            containLabel: true
          },
          legend: {
            show: false,
            orient: "horizontal",
            icon: "circle",
            // bottom: 0,
            x: "center",
            data: newData.xData,
            textStyle: { color: "#FFFDFE" }
          },
          series: newData
        };
        if (this.zhtitle.length > 0) {
          this.options.title = {
            text: this.zhtitle,
            left: "center",
            textStyle: {
              fontSize: 16,
              // fontWeight:"blod",
              color: "#fff"
            }
          };
        }
      },
      immediate: true,
      deep: true
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
